import request from '@/utils/request.js'

/**
 * 登录用户
 * @param {Object} userInfo 表单数据对象
 * @returns Promise
 */
export const login = userInfo => {
  return request.post('/home/login', userInfo)
}

/**
 * 注册用户
 * @param {Object} userInfo 用户信息对象
 * @returns Promise
 */
export const registe = userInfo => {
  return request.post('/home/registe', userInfo)
}

/**
 * 获取分类列表
 * @returns Promise
 */
export const reqCateList = () => {
  return request.get('/home/cate')
}

/**
 * 获取轮播图列表
 * @returns Promise
 */
export const reqSwiperList = () => {
  return request.get('/home/swiper')
}

/**
 * 获取广告列表
 * @returns Promise
 */
export const reqAdvList = () => {
  return request.get('/home/adv')
}

/**
 * 获取文章列表
 * @returns Promise
 */
export const reqContentList = () => {
  return request.get('/home/content')
}

export const reqContentByCid = cid => {
  return request.get(`/home/content/${cid}`)
}

/**
 * 获取热门列表
 * @returns Primose
 */
export const reqHotList = () => {
  return request.get('/home/hot')
}

/**
 * 根据ID获取文章详情
 * @param {Integer} id 文章ID
 * @returns Promise
 */
export const reqContentDetail = id => {
  return request.get(`/home/detail/${id}`)
}

/**
 * 点赞
 * @param {Integer} id 文章ID
 * @param {Integer} uid 用户ID
 * @returns Promise
 */
export const reqAddLike = id => {
  return request.post(`/home/like/${id}`)
}

/**
 * 评论
 * @param {Object} commentInfo 评论信息
 * @returns Promise
 */
export const reqAddComment = commentInfo => {
  return request.post('/home/comment', commentInfo)
}
